package org.catdroid.bomba.client;

import org.catdroid.bomba.controller.Controller;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class CatdroidActivity extends Activity implements OnClickListener {
    
	private EditText edt;
    private Controller controller;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button btn = (Button) findViewById(R.id.btnInit);
    btn.setOnClickListener(this);
    Button btn2 = (Button) findViewById(R.id.btnVer);
    btn2.setOnClickListener(this);
    
    controller = Controller.getInstance();
    
    edt = (EditText) findViewById(R.id.editInit);
}

    public void onClick(View v) {
            if (v.getId() == R.id.btnInit) {
                    if (edt.length() > 0)
                    {
                            controller.init(edt.getText().toString());
                            controller.joinGame();
                            Intent i = new Intent(this, GameListActivity.class);
                            i.putExtra("PLAYER", true);
                            startActivity(i);
                    }
            }
            else if (v.getId() == R.id.btnVer)
            {
                    Intent i = new Intent(this, GameListActivity.class);
                    i.putExtra("VOUYER", false);
                    startActivity(i);
            }
    }
}